//
//  MessageCommentCell.m
//  LiveStar
//
//  Created by 漪珊 on 2017/5/17.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "MessageCommentCell.h"
#import "TrendReplyModel.h"
#import "CommentModel.h"

@implementation MessageCommentCell

- (void)setTrendReplyModel:(TrendReplyModel *)trendReplyModel {
    _trendReplyModel = trendReplyModel;
    NSString *str  = nil;
    NSMutableAttributedString *text;
    if ([trendReplyModel.c_udid intValue] != [trendReplyModel.c_parudid intValue]) {
        str= [NSString stringWithFormat:@" %@ 回复 %@：%@",
              trendReplyModel.cnickname, trendReplyModel.pnickname, trendReplyModel.c_content];
        
        text = [[NSMutableAttributedString alloc] initWithString:str];
        [text addAttribute:NSForegroundColorAttributeName
                     value:UIColorFromRGB(0x0ACCAC)
                     range:NSMakeRange(trendReplyModel.cnickname.length+4, trendReplyModel.pnickname.length+2)];
        [text addAttribute:NSForegroundColorAttributeName
                     value:UIColorFromRGB(0x0ACCAC)
                     range:NSMakeRange(1, trendReplyModel.cnickname.length)];
    }else{
        str= [NSString stringWithFormat:@" %@：%@",
              trendReplyModel.cnickname, trendReplyModel.c_content];
        text = [[NSMutableAttributedString alloc] initWithString:str];
        [text addAttribute:NSForegroundColorAttributeName
                     value:UIColorFromRGB(0x0ACCAC)
                     range:NSMakeRange(1, trendReplyModel.cnickname.length)];
    }
    
    
    self.replyLabel.attributedText = text;
}

- (void)setCommentModel:(CommentModel *)commentModel {
    _commentModel = commentModel;
    NSString *str  = nil;
    NSMutableAttributedString *text;
    if ([commentModel.c_udid intValue] != [commentModel.c_parudid intValue]) {
        str= [NSString stringWithFormat:@" %@ 回复 %@：%@",
              commentModel.cnickname, commentModel.pnickname, commentModel.c_content];
        
        text = [[NSMutableAttributedString alloc] initWithString:str];
        [text addAttribute:NSForegroundColorAttributeName
                     value:UIColorFromRGB(0x0ACCAC)
                     range:NSMakeRange(commentModel.cnickname.length+4, commentModel.pnickname.length+2)];
        [text addAttribute:NSForegroundColorAttributeName
                     value:UIColorFromRGB(0x0ACCAC)
                     range:NSMakeRange(1, commentModel.cnickname.length)];
    }else{
        str= [NSString stringWithFormat:@" %@：%@",
              commentModel.cnickname, commentModel.c_content];
        text = [[NSMutableAttributedString alloc] initWithString:str];
        [text addAttribute:NSForegroundColorAttributeName
                     value:UIColorFromRGB(0x0ACCAC)
                     range:NSMakeRange(1, commentModel.cnickname.length)];
    }
    
    
    self.replyLabel.attributedText = text;
}
@end
